import { useState, useEffect } from "react"
//发接口请求拿数据
async function queryData() {
    const data = await new Promise((resolve) => {
        setTimeout(() => {
            resolve(666)//向then传值
        }, 2000)
    })
    return data
}
function App() {
    const [num, setNum] = useState(0)
    useEffect(() => {
        queryData().then(data => { //data为接收的666
            setNum(data)
        })
    }, [])
    return (
        <div onClick={() => {
            setNum((num) => num + 1)
        }}>{num}</div>
    )
}
export default App